n = int(input())
a = input()
mod = int(998244353)

dp = [[0]*(n+1) for _ in range(2)]
dp[0][0]=dp[1][0] = 1   #s的第0位只可取0/1
for i in range(1,n+1):
    if a[i-1] == "0":
        # i是a序列的索引dp[][i]代表a[i]左边的值是0还是1
        # 与运算时，若dp[0][i],若dp[0][i-1]，则右边0/1都可，所以*2
        dp[0][i]=(dp[0][i-1]*2+dp[1][i-1])%mod
        dp[1][i]=dp[1][i-1]
    elif a[i-1] == "1":
        dp[0][i]=dp[0][i-1]
        dp[1][i]=(dp[1][i-1]*2+dp[0][i-1])%mod
    elif a[i-1] == "2":
        dp[1][i] = dp[0][i] = (dp[0][i-1]+dp[1][i-1])%mod

print(dp[1][n])
